package etype

import "fmt"

const (
	UnknownError EntryError = iota + 9999
	Legal
	Illegal_Wellknown_view
	Illegal_StaticView
	Illegal_NotHTTP
	Illegal_UnknownUrl
	Illegal_Method
	Illegal_EmptyArgs
	Illegal_UnexpectedArgs
	Illegal_DiffusedArgs
)

type EntryError int

func (e EntryError) String() string {
	var description string
	switch e {
	case Legal:
		description = "Legal"
	case Illegal_Wellknown_view:
		description = "Illegal_Wellknown_view"
	case Illegal_Method:
		description = "Illegal_Method"
	case Illegal_StaticView:
		description = "Illegal_Static_View"
	case Illegal_EmptyArgs:
		description = "Illegal_Empty_Args"
	case Illegal_UnexpectedArgs:
		description = "Illegal_Unexpected_Args"
	case Illegal_DiffusedArgs:
		description = "Illegal_DiffusedArgs"
	case Illegal_UnknownUrl:
		description = "Unknown_Url"
	case UnknownError:
		description = "Unknown_Error"
	}
	return fmt.Sprintf("[%d]%s", e, description)
}

func Levels() map[EntryError]string {
	return map[EntryError]string{
		Legal:                  "合法访问",
		Illegal_Wellknown_view: "对常见未定义URL的访问（搜索引擎等）",
		Illegal_StaticView:     "对未定义静态文件的访问",
		Illegal_NotHTTP:        "非HTTP请求",
		Illegal_UnknownUrl:     "对未定义URL的访问",
		Illegal_Method:         "URL正确但调用方法不正确",
		Illegal_EmptyArgs:      "未提交要求提交的参数",
		Illegal_UnexpectedArgs: "提交了未要求提交的参数",
		Illegal_DiffusedArgs:   "参数滥用",
		UnknownError:           "其他未知错误",
	}
}
